﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ForgetPwdForm.aspx.cs"
    Inherits="FX.CC.Andon.WebSite.CommForm.ForgetPwdForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>修改密码</title>
    <script src="../lib/boot.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" method="post">
    <div style="padding-left: 11px; padding-bottom: 5px;">
        <table style="table-layout: fixed; padding-top: 10px;">
            <tr>
                <td>
                    账号：
                </td>
                <td style="width: 200px;">
                    <input name="LoginCode" id="LoginCode" style="width: 200px;" class="mini-textbox"
                        required="true" onvaluechanged="onLoginCodeChanged" />
                </td>
            </tr>
            <tr>
                <td>
                    原密码：
                </td>
                <td style="width: 200px;">
                    <input name="Pwd" id="Pwd" style="width: 200px;" class="mini-password" required="true"
                        onvaluechanged="onPwdChanged" />
                </td>
            </tr>
            <tr>
                <td>
                    新密码：
                </td>
                <td style="width: 200px;">
                    <input name="NewPwd" id="NewPwd" style="width: 200px;" class="mini-password" required="true" />
                </td>
            </tr>
        </table>
    </div>
    <div style="text-align: center; padding: 10px;">
        <a class="mini-button" iconcls="icon-save" onclick="onOk" style="width: 60px; margin-right: 20px;">
            保存</a> <a class="mini-button" iconcls="icon-cancel" onclick="onCancel" style="width: 60px;">
                取消</a>
    </div>
    <script type="text/javascript">
        mini.parse();
        var form = new mini.Form("form1");
        function onOk(e) {
            SaveData();
        }
        function CloseWindow(action) {
            if (action == "close" && form.isChanged()) {
                if (confirm("数据被修改了，是否先保存？")) {
                    return false;
                }
            }
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();
        }
        function SaveData() {
            var o = form.getData();
            var json = mini.encode([o]);
            form.validate();
            if (form.isValid() == false) return;
            $.ajax({
                url: "../Service/SystemManageHandler.ashx?action=ModifyPwd",
                data: { data: json },
                success: function (text) {
                    if (text) {
                        alert("密码修改成功!");
                    }
                    CloseWindow("save");
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                }
            });
        }
        function onLoginCodeChanged() {
            var LoginCode = mini.getbyName("LoginCode").getValue();
            if (LoginCode) {
                $.ajax({
                    url: "../service/PublicHandler.ashx?action=CheckedCode&tableName=UT_User&fieldName=LoginCode&Code=" + LoginCode,
                    success: function (text) {
                        if (text <= 0) {
                            mini.alert("账号不存在，请重新输入！");
                            mini.getbyName("LoginCode").setValue("");
                        }
                    },
                    error: function () {
                    }
                });
            }
        }
        function onPwdChanged() {
            var LoginCode = mini.getbyName("LoginCode").getValue();
            var Pwd = mini.getbyName("Pwd").getValue();
            if (LoginCode) {
                $.ajax({
                    url: "../service/PublicHandler.ashx?action=CheckedPwd&LoginCode=" + LoginCode + "&Pwd=" + Pwd,
                    success: function (text) {
                        if (text <= 0) {
                            mini.alert("原密码有误，请重新输入！");
                            mini.getbyName("Pwd").setValue("");
                        }
                    },
                    error: function () {
                    }
                });
            }
        }
        function GetData() {
            var o = form.getData();
            return o;
        }
        function onCancel(e) {
            CloseWindow("cancel");
        }
    </script>
    </form>
</body>
</html>
